#include "traverser.hpp"
#include <filesystem>


dcs::traverser_t::traverser_t(const std::filesystem::path& path)
	: path_(path)
{
}

dcs::traverser_t::~traverser_t()
{
}

std::set<std::tuple<std::filesystem::path, std::time_t>> dcs::traverser_t::run()
{
	std::set<std::tuple<std::filesystem::path, std::time_t>> paths;
	for (std::filesystem::directory_iterator iter(path_);
		iter != std::filesystem::directory_iterator{};
		++iter)
	{
		auto& entry = *iter;

		if (entry.is_directory())
			continue;

		const auto &file_path = entry.path();
		auto extension = file_path.extension().string();
		if (extension != ".CSV")
			continue;

		auto file_time = to_time(std::filesystem::last_write_time(file_path));
		paths.emplace(std::make_tuple(file_path, file_time));

	}

	return paths;
}
